'use strict'
const webpack = require('webpack')
const path = require('path')

/**
 * meipian.config.js for context
 * @param  {Object} jwconf meipian runtime congfig
 * @return {Object}        webpack config object
 */
module.exports = function(jwconf) {
  return {
    module: {
      rules: [{
        test: /\.hbs$/,
        loader: 'handlebars-loader',
        query: {
          helperDirs: [path.resolve(process.cwd(), jwconf.root, 'helper')]
        }
      }]
    },
    plugins: [
      new webpack.ProvidePlugin({
        $: 'jquery',
        jQuery: 'jquery',
        Handlebars: 'handlebars'
      })
    ]
  }
}
